import Vue from 'vue'



let status={

  modalImage: {
    isShow: false,
    isLoading: false,
  },
  modalDelete:{
    isShow: false,
    isLoading: false,
    deleteId:''
  }

}
// 页面的数据源
let data = {
  tabList: [],
};
let addModal={
  isShow:false,
  title:"新增标签",
  isLoading:false,
  modalImageSelect:{
    isShow:true
  },
  rules: {
    name: [
      {required: true, message: '名称不能为空', trigger: 'blur'}
    ],
  }
}
// 和网络交互相关的参数
let params = {
  tab:{
    id:'',
    name:'',
    icon:'',
  },
};

let  tabTableTitles=function (self) {
  var titles =  [
   {
      title: '序号',
      type: 'index',
      width: 100,
      align: 'center',
    },
  {
      title: '标签名称',
      align: 'center',
       key:'name',
      minWidth:150
    },
  {
      title: '标签图标',
      width: 150,
      key:'icon',
      align: 'center',
    render: (h, params) => {
      let imageUrl = Vue.prototype.$store.getters.imgPrefix + params.row.icon;
      return '' ===  params.row.icon ? '' : h('img', {
        attrs: {src: imageUrl, height: 60 },
        on: {
          click: () => {
            // status.modalImage.url = imageUrl;
            // status.modalImage.isShow = true;
          }
        }
      })
    },
    },
    {
      title: '创建时间',
      align: 'center',
      minWidth:150,
      render: (h, params) => {
        return h('div',self.$tiyBJTime(params.row.createtime));
      },
    },
    !self.$authority('PRODUCT-3-205')?null:{
      title: '综合操作',
      key: 'action',
      align: 'center',
      minWidth:200,
      render: (h, params) => {
        return h('div', [
            h('Button', {
              props: {type: 'primary', size: 'small', icon: "md-create",},
              style: {marginRight: '8px'  },
              on: {
                click: () => {
                  self.editTab(params.index)
                }
              }
            }, "编辑"),
            h('Button', {
              props: {type: 'error', size: 'small', icon: "md-trash",},
              style: {marginRight: '8px'  },
              on: {
                click: () => {
                  self.deleteTab(params.index)
                }
              }
            }, '删除'),
          ]
        )
      }

  }
]

  return self.$authTableTitles(titles)

}
export  default  {
  tParam: params,
  addModal:addModal,
  tData: data,
  listTableTitles:tabTableTitles,
  tStatus:status
};

